home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2003 September / PC Answers September 2003.iso / Software / trial / MonitorIT 5.2.06 / monitorit_fullsetup.exe / data1.cab / Js / AlertFunc.js < prev    next >
Encoding:
JavaScript  |  2003-06-24  |  7.5 KB  |  229 lines

  1. /* ======================================================================
  2. DESC: Common Alert Functions for the Administer/Analyze Operations
  3.  
  4. PLATFORMS: >= MS IE 4.0
  5.  
  6. USAGE NOTES: 
  7. ====================================================================== */
  8.  
  9. var    AlertRecLength = 24; // Alert Lookup record length
  10.  
  11. /* Process Alert LOOKUP RECORD Event */
  12. function AlertLupRecPart1(AlID, AlName, AlDesc, AlThresh, AlOver, AlEveryTime, AlDur, AlSched, AlSDT, AlEDT, AlArrayIDs) {
  13.     AlDependencyID = "";
  14.     if ( AlSDT == "01/01/1999 11:30:00" || AlSDT == "1/1/1999 11:30:0" ) { // Service type
  15.         if ( top.banner.CurrentPageName == "AdminAlerts" ) {
  16.             addElementToSelect(AL_DependencySel,AlName); // populate the Dependency choice
  17.         }
  18.     }    
  19.     // Parse Out Dependency, Suppress Monitoriing & CounterWatch Max Alerts
  20.     var di = AlDesc.indexOf("[]");
  21.     if ( di >= 0 ) {
  22.         AlDependencyID = AlDesc.substr(di+2);
  23.         AlDesc = AlDesc.substr(0,di);
  24.     }
  25.     
  26.     var i = AlertLupRecCount * AlertRecLength;
  27.     if ( getAlertName(AlID) == "" ) { // if not received yet
  28.         addElementToSelect(AL_AlertSel,AlName); 
  29.         AlertStoreArr[i++] = AlName; //+0
  30.         AlertStoreArr[i++] = AlID;
  31.         AlertStoreArr[i++] = AlDesc;
  32.         AlertStoreArr[i++] = AlThresh;
  33.         AlertStoreArr[i++] = AlOver; //+4
  34.         AlertStoreArr[i++] = AlEveryTime;
  35.         AlertStoreArr[i++] = AlDur;
  36.         AlertStoreArr[i++] = AlSched;
  37.         AlertStoreArr[i++] = AlSDT;
  38.         AlertStoreArr[i++] = AlEDT; //+9
  39.         AlertStoreArr[i++] = AlArrayIDs; //+10
  40.         /* allocate space for Part 2 */
  41.         AlertStoreArr[i++] = ""; //+11
  42.         AlertStoreArr[i++] = "";
  43.         AlertStoreArr[i++] = "";
  44.         AlertStoreArr[i++] = ""; //+14
  45.         AlertStoreArr[i++] = "";
  46.         AlertStoreArr[i++] = "";
  47.         AlertStoreArr[i++] = "";
  48.         AlertStoreArr[i++] = "";
  49.         AlertStoreArr[i++] = ""; //+19
  50.         AlertStoreArr[i++] = "";
  51.         AlertStoreArr[i++] = "";
  52.         AlertStoreArr[i++] = ""; //+22
  53.         AlertStoreArr[i++] = AlDependencyID; //+23
  54.     }
  55.     else { // already received Part 2, update Part 1
  56.         ASix = AlertSelectIdx * AlertRecLength;
  57.         AL_AlertSel.options[ASix].text = AlName;
  58.         AlertStoreArr[ASix+0] = AlName;
  59.         AlertStoreArr[ASix+2] = AlDesc;
  60.         AlertStoreArr[ASix+3] = AlThresh;
  61.         AlertStoreArr[ASix+4] = AlOver;
  62.         AlertStoreArr[ASix+5] = AlEveryTime;
  63.         AlertStoreArr[ASix+6] = AlDur;
  64.         AlertStoreArr[ASix+7] = AlSched;
  65.         AlertStoreArr[ASix+8] = AlSDT;
  66.         AlertStoreArr[ASix+9] = AlEDT;
  67.         AlertStoreArr[ASix+10] = AlArrayIDs;
  68.     }
  69.     ++AlertLupRecCount; // bump record received counter
  70. }
  71.  
  72. function AlertLupRecPart2(AlID, AlRunProg, AlProgNme, AlProgramArgs, AlENotify, AlEAddr, AlESubj, AlPhNotify, AlPhNumber, AlTextToSpeak, AlPgNotify, AlPgNumber, AlTextToSend) {
  73.     UNameObj = document.all.AL_AlertSel; // Alert Name Combo box
  74.     if ( getAlertName(AlID) == "" ) { // if not received yet
  75.         // allocate space for Part 1
  76.         AlertStoreArr[i++] = "name"; //+0
  77.         AlertStoreArr[i++] = AlID;
  78.         AlertStoreArr[i++] = "";
  79.         AlertStoreArr[i++] = "";
  80.         AlertStoreArr[i++] = ""; //+4
  81.         AlertStoreArr[i++] = "";
  82.         AlertStoreArr[i++] = "";
  83.         AlertStoreArr[i++] = "";
  84.         AlertStoreArr[i++] = "";
  85.         AlertStoreArr[i++] = ""; //+9
  86.         AlertStoreArr[i++] = ""; //+10
  87.         /* save Part 2 */
  88.         AlertStoreArr[i++] = AlRunProg; //+11
  89.         AlertStoreArr[i++] = AlProgNme;
  90.         AlertStoreArr[i++] = AlProgramArgs;
  91.         AlertStoreArr[i++] = AlENotify; //+14
  92.         AlertStoreArr[i++] = AlEAddr;
  93.         AlertStoreArr[i++] = AlESubj;
  94.         AlertStoreArr[i++] = AlPhNotify;
  95.         AlertStoreArr[i++] = AlPhNumber;
  96.         AlertStoreArr[i++] = AlTextToSpeak; //+19
  97.         AlertStoreArr[i++] = AlPgNotify;
  98.         AlertStoreArr[i++] = AlPgNumber;
  99.         AlertStoreArr[i++] = AlTextToSend; //+22
  100.         AlertStoreArr[i++] = ""; //+23
  101.     }
  102.     else { // already received Part 2, update Part 1
  103.         ASix = AlertSelectIdx * AlertRecLength;
  104.         AlertStoreArr[ASix+11] = AlRunProg;
  105.         AlertStoreArr[ASix+12] = AlProgNme;
  106.         AlertStoreArr[ASix+13] = AlProgramArgs;
  107.         AlertStoreArr[ASix+14] = AlENotify;
  108.         AlertStoreArr[ASix+15] = AlEAddr;
  109.         AlertStoreArr[ASix+16] = AlESubj;
  110.         AlertStoreArr[ASix+17] = AlPhNotify;
  111.         AlertStoreArr[ASix+18] = AlPhNumber;
  112.         AlertStoreArr[ASix+19] = AlTextToSpeak;
  113.         AlertStoreArr[ASix+20] = AlPgNotify;
  114.         AlertStoreArr[ASix+21] = AlPgNumber;
  115.         AlertStoreArr[ASix+22] = AlTextToSend;
  116.     }
  117. }
  118.  
  119. /* Process Combo Alert Name Change Event */
  120. function processAlertName() {
  121.     if ( ALupMode != "" || AL_AlertSel.disabled == "disabled") 
  122.         return; // ignore if Busy
  123.     Nobj = document.all.AL_AlertSel; // get object
  124.     for (i=0; i < Nobj.length; ++i) {
  125.         if ( Nobj.options[i].selected ) {
  126.             AlertSelectIdx = i;
  127.             document.all.AL_AlertSel.blur(); // take focus away
  128.             populateInput(AlertRecLength*i);
  129.             break;
  130.         }
  131.     }
  132. }
  133.  
  134. /* Process DB Error in Alert Lookup Operation */
  135. function processAlertOpError() {
  136.     top.Rstatus.Pstat("An error occurred during Alert LOOKUP operation",true);
  137.     processResetButton(); // reset
  138. }
  139.  
  140. /* Get Alert Name from Store based on Alert ID */
  141. function getAlertName(UID) {
  142.     AlertName = "";
  143.     for (i=0, j=0; i < AlertStoreArr.length; ++j, i+=AlertRecLength) {
  144.         if ( AlertStoreArr[i+1] == UID ) {
  145.             AlertName = AlertStoreArr[i];
  146.             AlertSelectIdx = j;
  147.             document.all.AL_AlertSel.options[j].selected = "selected";
  148.             break;
  149.         }
  150.     }
  151.     return AlertName;
  152. }
  153.  
  154. /* Get Alert ID from Store based on Alert Name */
  155. function getAlertID(UNM) {
  156.     UID = 0;
  157.     for (i=0, j=0; i < AlertStoreArr.length; ++j, i+=AlertRecLength) {
  158.         if ( AlertStoreArr[i] == UNM ) {
  159.             AlertSelectIdx = j;
  160.             UID = AlertStoreArr[i+1];
  161.             break;
  162.         }
  163.     }
  164.     return UID;
  165. }
  166.  
  167. /* Process Duplicate Error in Alert Add / Replace Operation */
  168. function processAlertUpdateErrorDuplicate() {
  169.     top.Rstatus.Pstat("A duplicate Alert already exists in the DataBase. Cannot complete the UPDATE request",true);
  170.     alert("A Watch/Alert already exits with this Name. Please specify a unique Name for this Watch/Alert");
  171.     SetButtonState(UUpdateButton,"0");
  172. }
  173.  
  174. /* Process Alert ID Not Found Error in EDIT/UPDATE Operation */
  175. function processAlertUpdateErrorBadAlert() {
  176.     top.Rstatus.Pstat("Alert not found in the DataBase. Cannot complete the UPDATE/DELETE request",true);
  177.     processResetButton(); // reset
  178. }
  179.  
  180. /* Get Object Name and Description from Store based on Object ID */
  181. function getObjectName(OID) {
  182.     var IDAr = new Array(); // ID array
  183.     var OCAr = new Array(); // Individual Object,Computer
  184.     for (var i=0, j=0; i < AL_OCStoreArr.length; ++j, i+=ObjectRecLength) {
  185.         IDAr = AL_OCStoreArr[i+2].split(";"); // get ID Array
  186.         for ( var k=0; k<IDAr.length; k++ ) {
  187.            OCAr = IDAr[k].split(",");
  188.             if ( OCAr[0] == OID ) {
  189.                 CurObjIx = j; // Ibject index
  190.                 Odsc = AL_OCStoreArr[i+1]; // description
  191.                 if ( Odsc.charAt(0) == "{" ) { // if instance
  192.                     k = i; // get/preserve Object index
  193.                     while ( (k-=ObjectRecLength) >= 0 ) {
  194.                         if ( AL_OCStoreArr[k+1] == Odsc ) {
  195.                             continue; // if another instance
  196.                         }
  197.                         else {
  198.                             Odsc = AL_OCStoreArr[k+1];
  199.                             break;
  200.                         }                            
  201.                     } // end While
  202.                }
  203.                 return  AL_OCStoreArr[i] + "," + Odsc;
  204.             }
  205.         }
  206.     }
  207.     return null;
  208. }
  209.  
  210. /* Process DB Error in Object Lookup Operation */
  211. function processObjectOpError() {
  212.     top.Rstatus.Pstat("An error occurred during Object LOOKUP operation",true);
  213.     processResetButton(); // reset
  214. }
  215.  
  216. /* Process DB Error in Counter Lookup Operation */
  217. function processCounterOpError() {
  218.     top.Rstatus.Pstat("An error occurred during Counter LOOKUP operation",true);
  219.     processResetButton(); // reset
  220. }
  221.  
  222. /* Process DB Error in Computer Lookup Operation */
  223. function processComputerOpError() {
  224.     top.Rstatus.Pstat("An error occurred during Computer LOOKUP operation",true);
  225.     processResetButton(); // reset
  226. }
  227.  
  228.  
  229.